package com.common.frame.utils;


import android.hardware.Camera;
import android.util.Log;

/**
 * @author: sunxy11
 * @email: sunxy11@iflytek.com
 * @date: 2021/12/25
 */
public class CameraUtils {

    public static final int CAMERA_BACK = 1;
    public static final int CAMERA_FRONT = 2;
    //无人机可见光
    public static final int CAMERA_UAV_NORMAL = 4;
    //无人机红外
    public static final int CAMERA_UAV_INFRARED = 8;

    /**
     * 后置 1
     * 前置 2
     * 无人机可见光 4
     */

    public static int getCurrentDeviceCameraInfo() {
        if (Camera.getNumberOfCameras() == 2)  {
            return CAMERA_BACK + CAMERA_FRONT;
        }
        return CAMERA_BACK;
    }

    public static int getShowCameraId(int cameraInfo) {
        if (cameraInfo == CAMERA_FRONT) {
            return Camera.CameraInfo.CAMERA_FACING_FRONT;
        }
        return Camera.CameraInfo.CAMERA_FACING_BACK;
    }

    public static boolean typeIsSelect(int type, int cameraType) {
        return (type & cameraType) == cameraType;
    }

}
